package service;

import dao.GoodsDao;
import model.Page;

import java.sql.SQLException;
import java.util.List;

public class GoodsService {
    private GoodsDao gDao=new GoodsDao();

    //根据商品类别id进行分页
    public Page selectPageByTypeID(int typeID, int pageNumber) {
        Page p=new Page();
        p.setPageNumber(pageNumber);
        int totalCount=0;
        try {
            totalCount=gDao.getCountOfGoodsByTypeID(typeID);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        p.SetPageSizeAndTotalCount(8,totalCount);

        List list=null;
        try {
            list=gDao.selectGoodsByTypeID(typeID,pageNumber,8);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        p.setList(list);
        return p;
    }
}
